@extends('.layouts.adminLayouts')

@section('mainContent')

    <div class="box">
        <div class="box-header">
            <h3 class="box-title">菜单管理</h3>
        </div>

        <div class="box-body">

            <div class="col-md-6">

                <table class="table">
                    @forelse($query as $row)
                        <tr>
                            <td>
                                <i class="{{$row['icon']}}"></i>
                                {{$row['name']}}
                            </td>

                            <td width="100">
                                <a href="{{route('admin.menu.edit',$row['id'])}}">编辑</a>
                            </td>

                        </tr>
                        @foreach($row['son'] as $name)
                            <tr>
                                <td>{{str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $row['laraevl'] + 2)}}
                                    <i class="{{$name['icon']}}"></i>
                                    {{$name['name']}}
                                </td>
                                <td width="100">
                                    <a href="{{route('admin.menu.edit',$name['id'])}}">编辑</a>
                                </td>
                            </tr>

                            @foreach($name['son'] as $v)
                                <tr>
                                    <td>
                                        {{str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $row['laraevl'] + 4)}}
                                        <i class="{{$v['icon']}}"></i>
                                        {{$v['name']}}
                                    </td>
                                    <td width="100">
                                        <a href="{{route('admin.menu.edit',$v['id'])}}">编辑</a>
                                    </td>
                                </tr>
                            @endforeach
                        @endforeach
                    @empty
                        <tr>
                            <td>暂时没有数据</td>
                        </tr>
                    @endforelse
                </table>

            </div>

            <div class="col-md-6">

                <form class="form-horizontal" action="" method="POST">

                    <div class="form-group">
                        <label class="control-label col-md-2">上级编号</label>
                        <div class="col-md-10">

                            <select class="select2Console form-control" name="data[parent_id]">

                                <option value="0">顶级编号</option>
                                @forelse($query as $row)

                                    <option value="{{$row['id']}}">{{$row['name']}}</option>
                                    @foreach($row['son'] as $name)
                                        <option value="{{$name['id']}}">
                                            {{str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $row['laraevl'] + 2)}}{{$name['name']}}
                                        </option>
                                        @foreach($name['son'] as $v)
                                            <option value="{{$v['id']}}">
                                                {{str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $row['laraevl'] + 4)}}{{$v['name']}}
                                            </option>
                                        @endforeach
                                    @endforeach
                                @empty

                                @endforelse

                            </select>

                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">菜单名称</label>
                        <div class="col-md-10">
                            <input type="text" class="form-control" name="data[name]">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">连接</label>
                        <div class="col-md-10">
                            <input type="text" class="form-control" name="data[url]">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">控制器</label>
                        <div class="col-md-10">
                            <input type="text" class="form-control" name="data[controller]">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">系统调用名</label>
                        <div class="col-md-10">
                            <input type="text" class="form-control" name="data[sulg]">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">图标</label>
                        <div class="col-md-10">
                            <input type="text" name="data[icon]" class="fontIconPicker"/>
                            <span class="help-block">
                                <i class="fa fa-info-circle"></i>&nbsp;字体详情可以查看
                                <a href="http://fontawesome.io/icons/"
                                   target="_blank">http://fontawesome.io/icons/</a>
                            </span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">图标</label>
                        <div class="col-md-10">
                            <input type="checkbox" name="data[is_show]" value="1"/>菜单显示?
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-2"></div>
                        <div class="col-md-10">
                            {{csrf_field()}}
                            <div class="btn-group pull-left">
                                <button type="submit" class="btn btn-default">提交</button>
                            </div>

                            <div class="btn-group pull-right">
                                <button type="reset" class="btn btn-danger">取消</button>
                            </div>
                        </div>
                    </div>

                </form>

            </div>

        </div>

    </div>

@endsection
